#include <gnome.h>

typedef struct 
{
	GtkWidget *fixed;
	GtkWidget *button;
}ButtonMover;

#define WIDTH 400
#define HEIGHT 300

void cb_button_clicked(GtkWidget *self,ButtonMover *bm){
	gint x = random() % WIDTH;
	gint y = random() % HEIGHT;
	gchar *tmp = g_strdup_printf("(%d,%d)",x,y);
	gtk_button_set_label(GTK_BUTTON(self),tmp);
	gtk_fixed_move(GTK_FIXED(bm->fixed),bm->button,x,y);
}

GtkWidget *makeFixedContainer(void){
	GtkWidget *fixed;
	static ButtonMover bm[3];

	fixed = gtk_fixed_new();
	for(int i = 0;i < 3;i++){
		bm[i].fixed = fixed;
		bm[i].button = gtk_button_new_with_label("(100,100)");
		gtk_signal_connect(GTK_OBJECT(bm[i].button),"clicked",GTK_SIGNAL_FUNC(cb_button_clicked),&bm[i]);
		gtk_fixed_put(GTK_FIXED(fixed),bm[i].button,100,100);
	}
	return fixed;
}


int main(int argc,char *argv[]){
	GtkWidget *w,*fixed;

	gnome_init("fixed","1.0",argc,argv);
	w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size(GTK_WINDOW(w),WIDTH,HEIGHT);
	gtk_signal_connect(GTK_OBJECT(w),"destroy",G_CALLBACK(gtk_main_quit),NULL);
	fixed = makeFixedContainer();
	gtk_container_add(GTK_CONTAINER(w),fixed);
	gtk_widget_show_all(w);
	gtk_main();

	return 0;
}
